#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
using namespace std;
class Solution {
    public:
        string to(string a,int k)
        {return a+='('+to_string(k)+')';}
        vector<string> getFolderNames(vector<string>& names) {
            unordered_map<string, int>map;
            vector<string>ans;
            for(const auto &name:names)
            {
                map[name]++;
                if(map[name]==1)
                {
                    ans.push_back(name);
                }
                else {
                    int k=map[name];
                    while(map[to(name, k-1)])
                    {
                        k++;
                    }
                    ans.push_back(to(name,k-1));
                    map[to(name,k-1)]++;
                }          
            }
            return ans;
        }
    };